/**
 * Copyright © 2024, ZhiYun Network Co.,Ltd. All rights reserved.
 * ZhiYun PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.itcoon.cloud.framework.transform.utils;

import java.util.Collection;
import java.util.function.Supplier;

/**
 * ClassName:com.itcoon.utils.transform.framework.CollectionFactory
 * Description:
 *
 * Date: 10/4/24 11:27 AM
 *
 * @author: miaoxia.yu
 *
 * @version 1.0.0
 */
public class CollectionFactory<T, TT extends Collection<T>> implements Supplier<Collection<T>> {

    private final Class<TT> collectType;
    private final Class<T> elementType;
    private final int capacity;

    public CollectionFactory(Class<TT> collectType, Class<T> elementType, int capacity) {
        this.collectType = collectType;
        this.elementType = elementType;
        this.capacity = capacity;
    }


    @Override
    public TT get() {
        return (TT)org.springframework.core.CollectionFactory.createCollection(collectType, elementType, capacity);
    }
}
